home *** CD-ROM | disk | FTP | other *** search
/ The Epic Collection 3 / Epic Collection 3, The (1997)(Epic Marketing)[!].iso / useful_tools / toolmanager / goodies / getpubname.lha / GetPubName / GetPubName.mod < prev    next >
Text File  |  1992-09-26  |  4KB  |  122 lines

  1.  
  2. (*=============================================================================
  3. :Program.       GetPubName
  4. :Contents.      An easy Program, which only returns the Name of the frontmost
  5. :Contents.       PubScreen
  6. :Author.        Michael `Mick' Hohmann
  7. :Address.       Carl-Schilling-Str. 10; 8701 Kirchheim
  8. :Address.       UUCP: mickh@imart.franken.de
  9. :Phone.         09 31 / 54 1 55
  10. :Copyright.     Freely Distributable
  11. :Language.      Oberon
  12. :Translator.    AmigaOberon 2.39d
  13. :Imports.       MoreIntuition
  14. :History.       v0.01 just did an WriteString -- nothing else
  15. :History.       v1.1 finished -- I hope so ;-))
  16. :History.       v1.2 Always creates an ENV-Var -- Bug Fixed
  17. :History.       v1.3 translated to Oberon
  18. :History.       v1.4 again some Bugfixes -- thanx to `tron'
  19. :Thanx.         done WITH much much Help from Jürgen Weinelt
  20. =============================================================================*)
  21.  
  22. MODULE GetPubName;
  23.  
  24. IMPORT
  25.   D:=Dos,
  26.   E:=Exec,
  27.   I:=Intuition,
  28.   MI:=MoreIntuition,
  29.   OL:=OberonLib,
  30.   SYSTEM;
  31.  
  32.  
  33. CONST
  34.   strLen             = 80;
  35.   argTemplate        = "ENV=ENVIRONMENT,LOC=LOCAL/S,HELP/S";
  36.   oProgName          = "GetPubName 1.4";
  37.   date               = "(Saturday 26 Sep 1992)";
  38.   versionString      = "$VER: GetPubName 1.4 (Saturday 26 Sep 1992)";
  39.   need20             = "This programm needs Kick 2.04! Sorry!";
  40.  
  41.  
  42. TYPE
  43.   String             = ARRAY 256 OF CHAR;
  44.   StringPtr          = POINTER TO String;
  45.   PubString          = ARRAY I.maxPubScreenName+1 OF CHAR;
  46.   DosArgs            = STRUCT
  47.                          env   : StringPtr;
  48.                          local : LONGINT;
  49.                          help  : LONGINT
  50.                        END;
  51.  
  52.  
  53. VAR
  54.   envName            : ARRAY strLen OF CHAR;
  55.   pubScrName         : PubString;
  56.   activeScreen       : I.ScreenPtr;
  57.   dArgs              : DosArgs;
  58.   envType            : LONGSET;
  59.   progName           : ARRAY 33 OF CHAR;
  60.  
  61.  
  62. BEGIN
  63.   (** Das Programm laeuft nur >= Kick 2.x **)
  64.   IF OL.wbStarted THEN HALT(20); END; (* sinnlos von WB *)
  65.   IF D.dos.lib.version < 37 THEN
  66.     IF D.Write(D.Output(),need20,SIZE(need20))=0 THEN END;
  67.     HALT(20);
  68.   END;
  69.   SYSTEM.SETREG(0,SYSTEM.ADR(versionString));
  70.   IF ~D.GetProgramName(progName,30) THEN progName:=oProgName; END;
  71.  
  72.   (** Initialisierung der Variablen **)
  73.   envName:="FrontPubName";
  74.   dArgs:=DosArgs(NIL,0,0);
  75.   pubScrName:="";
  76.   envType:=LONGSET{};
  77.   activeScreen:=MI.LockFrontPubScr(pubScrName);  (** Den vordersten PubScreen, oder die WB locken **)
  78.  
  79.   (** Get Arguments from CLI and write the Name to StdOut or to an ENV-Var **)
  80.   IF D.ReadArgs(argTemplate,dArgs,NIL)#NIL THEN
  81.  
  82.     IF dArgs.help#0 THEN
  83.       IF D.WriteStr("\n\[33m") THEN END;
  84.       IF D.WriteStr(oProgName) THEN END;
  85.       IF D.WriteStr("\[0m © 1992 by Michael `Mick' Hohmann ") THEN END;
  86.       IF D.WriteStr(date) THEN END;
  87.       IF D.WriteStr("\n\nGetPubName returns the Name of the FrontMost PublicScreen\neither to StdOut or if specified as an Global-Variable.\n\n") THEN END;
  88.       HALT(0)
  89.     END;
  90.  
  91.     IF dArgs.env#NIL THEN
  92.       COPY(dArgs.env^,envName)
  93.     ELSE
  94.       IF D.WriteStr(pubScrName) THEN END;
  95.       HALT(0)
  96.     END;
  97.  
  98.     IF dArgs.local#0 THEN
  99.       INCL(envType,D.localOnly)
  100.     ELSE
  101.       INCL(envType,D.globalOnly)
  102.     END;
  103.  
  104.   ELSE
  105.     IF D.WriteStr("\n== Command line syntax error ==\n") THEN END;
  106.     HALT(15)
  107.   END;
  108.  
  109.   IF ~D.SetVar(envName,pubScrName,SIZE(pubScrName),envType) THEN
  110.    IF D.WriteStr("\n== Sorry, couldn't create the ENV-Variable ==\n") THEN END;
  111.    HALT(15)
  112.   END
  113.  
  114.  
  115. CLOSE
  116.  
  117.   IF activeScreen#NIL THEN
  118.     I.UnlockPubScreen(NIL,activeScreen);
  119.   END;
  120.  
  121. END GetPubName.
  122.